<script type="text/javascript"><!--//--><![CDATA[//><!--
	console.clear();
    
    var grid_reload = function() {
        $('#datagrid').datagrid('reload', $('#fm_search').serializeObject());
    };

    $(document).ready(function() {
    	$('#nama_karyawan_cari').readonly();

		$('#fm_search').setupForm([
			{ name: 'id_karyawan_cari', type: 'lov', size: 'short', 
				onClearButton:function(){
					$(this).setval(''); 
					$('#nama_karyawan_cari').setval('');
					grid_reload();
				},
				onActionButton:function(){ 
					LOVHrdKaryawan({ onSelect:function(row){ 
						$('#id_karyawan_cari').setval(row.id_karyawan_pk); 
						$('#nama_karyawan_cari').setval(row.nama_karyawan); 
						grid_reload();
					} });
				}
			},
            { name: 'id_periode_cari', type:'combo', size:'medium', data:<?php echo json_encode($listPeriode); ?>, onChange:grid_reload }
		]);

		// Setup Datagrid
		$('#datagrid').datagrid({  
			url:gs_path+'/'+controller+'/getdata', 
			queryParams: $('#fm_search').serializeObject(),
			height:405,
			fitColumns:true,
			pagination:true,
			// singleSelect:true,
			frozenColumns: [[
				{ field : 'ck', checkbox:true, width: 40, align: 'center' },
                { field : 'id_asuransi_triwulan_pk', title : 'ID', width : 100, sortable:true },
				{ field : 'id_karyawan_fk', title : 'NIK', width : 100, sortable:true },
				{ field : 'nama_karyawan', title : 'Nama Karyawan', width : 200, sortable:true },
			]],
			columns:[[
                { field : 'nama_periode', title : 'Periode', width : 80, sortable:true },
				{ field : 'nilai', title : 'Nilai', width : 80, sortable:true, formatter:formatNumeric, align:'right' },
			]],
			rownumbers: true
		});

        // Create Dialog
        $('#dialog_container').dialog({
            closed:true,
            modal:true,
            title: '_',
            width:600,
            buttons:[{
                text:'Save',
                iconCls:'icon-save',
                handler:function(){
                    $('#form_master').submitForm('/'+controller+'/ajax_post', { onComplete : function(){ $('#dialog_container').dialog('close'); $('#datagrid').datagrid('reload'); }} );
                }
            },{
                text:'Close',
                iconCls:'icon-cancel',
                handler:function(){
                    $('#dialog_container').dialog('close');
                }
            }]
        });
        
        // Set Action Button
        var buttons = [ 
            { label: 'Import', icon: 'up', onclick: function() {
                /*var oSel = $('#datagrid').datagrid('getSelected'); */
                
                var $popup = openPopup({ title: '&nbsp;', 
                    width: 875,
                    height: 470,
                    url: gs_path + '/' + controller + '/form_import/'
                 });
            }},
            { label: 'Delete', icon: 'delete', onclick: function() { 
                var oSel = $('#datagrid').datagrid('getSelected'); 
                if (oSel == null) { 
                    $.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
                } else { 
                    deleteData(['id_asuransi_triwulan_pk']);
                } 
            }}
        ];
        setAction(buttons);
		
		
		$('#fm_search').focusFirst();
    });
//--><!]]>
</script>

    
<div id="tb" style="padding:5px;height:auto">
    <div>
        <form id="fm_search" method="post" onsubmit="grid_reload(); return false;">
        	<table class="tb_form" style="margin-bottom:0px">
            <tr>
            	<td width="100">Karyawan</td>
                <td><input type="text" id="id_karyawan_cari" name="id_karyawan_cari" class="textfield short" /> <input type="text" id="nama_karyawan_cari" name="nama_karyawan_cari" class="textfield medium" /></td>
            </tr>
            <tr>
            	<td>Periode</td>
                <td>
                    <input id="id_periode_cari" />
                	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload(); return false;">Search</a>
                    <input type="submit" style="display:none" />
                </td>
            </tr>
            </table>
        </form>
    </div>
</div>
<div id="datagrid" toolbar="#tb"></div>